package com.some;

import java.util.Scanner;

public class WeBank02 {
    public int[] minStep(int[][] nums) {
        int[] res = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            res[i] = dealNum(nums[i]);
        }
        return res;
    }

    public int dealNum(int[] nums) {
        int times = 0;
        int a = nums[0];
        int b = nums[1];
        if (a > b) {
            // a小b大
            a = nums[1];
            b = nums[0];
        } else if (a == b) {
            return 0;
        } else if (b%2!=0){
            return -1;
        }
        while (a != b) {
            if (a < b && (a * 2 > b || a > Integer.MAX_VALUE / 2)) {
                return -1;
            }
            if (a > b && (b * 2 > a || b > Integer.MAX_VALUE / 2)) {
                return -1;
            }
            if (a * 2 <= b) {
                times++;
                a = a * 2;
            }
        }
        if (times <= 3) {
            return 1;
        }

        return (times % 3) != 0 ? (times / 3) + 1 : (times / 3);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[][] nums = new int[t][2];
        for (int i = 0; i < t; i++) {
            nums[i][0] = sc.nextInt();
            nums[i][1] = sc.nextInt();
        }
        WeBank02 weBank02 = new WeBank02();
        for (int i : weBank02.minStep(nums)) {
            System.out.println(i);
        }
    }
}
